package cn.itcast.erp.entity;

import java.io.Serializable;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.io.Serializable;
import java.util.List;

import cn.itcast.erp.entity.utils.Base;
import com.alibaba.fastjson.annotation.JSONField;
import com.fasterxml.jackson.annotation.JsonFormat;
import org.springframework.stereotype.Component;

import javax.validation.constraints.*;

/**
 * 员工实体类
 * @author Administrator *
 */
@Component
public class Emp extends Base implements Serializable {

    public interface LoginGroup{};
	public interface  interGroup{};
	public interface  updatePwd{};

	//编号
	private Long uuid;

	@NotBlank(groups = {LoginGroup.class,interGroup.class},message = "登录名不能为空")
	@Pattern(regexp = "^[0-9a-zA-Z]+$",message = "用户名只能由字母和数字组成")
	//用户名重复验证
	private String username;//登陆名
	//不转换json字符串
	@JSONField(serialize=false)
	@NotBlank(groups = {LoginGroup.class,updatePwd.class},message = "密码不能为空")
	private String pwd;//登陆密码
	@NotBlank(groups = {updatePwd.class},message = "密码不能为空")
	private String newPwd;
	private String name;//真实姓名


	@NotNull(groups ={interGroup.class}, message = "性别不能为空")
	@DecimalMax (value = "1",message ="性别选择不符合规则" )
	@DecimalMin (value = "0",message = "性别选择不符合规则")
	private Long gender;//性别

    @NotBlank(groups = {interGroup.class},message = "邮箱不能为空")
    @Pattern (regexp = ".*^[a-zA-Z0-9_.-]+@[a-zA-Z0-9-]+(\\.[a-zA-Z0-9-]+)*\\.[a-zA-Z0-9]{2,6}$*",message = "邮箱格式不符合规则")//只允许英文字母、数字、下划线、英文句号、以及中划线组成
    private String email;//邮件地址

	@NotBlank(groups = {interGroup.class},message = "电话不能为空")
	@Pattern (regexp = "1[345678][0-9]{9}",message = "手机号不符合规则")
	private String tele;//联系电话
	private String address;//联系地址

	@JsonFormat(pattern = "yyyy-MM-dd",timezone = "GMT+8")
	@NotNull(groups = {interGroup.class},message = "生日不能为空")
	@Past(message = "生日不能是未来日")
	private java.util.Date birthday;//出生年月日

	@NotNull(groups = {interGroup.class},message = "部门不能为空")
	private Long depuuid;//部门id

	private Dep dep;//部门
	private java.util.Date birthdayFrom;//出生年月日
	private java.util.Date birthdayTo;//出生年月日
	@JSONField(serialize=false)
	private List<Role> roles;//用户下所拥有的角色集合

	@Override
	public String toString() {
		return "Emp{" +
				"uuid=" + uuid +
				", username='" + username + '\'' +
				", pwd='" + pwd + '\'' +
				", name='" + name + '\'' +
				", gender=" + gender +
				", email='" + email + '\'' +
				", tele='" + tele + '\'' +
				", address='" + address + '\'' +
				", birthday=" + birthday +
				", dep=" + dep +
				", birthdayFrom=" + birthdayFrom +
				", birthdayTo=" + birthdayTo +
				", depuuid=" + depuuid +
				", roles=" + roles +
				'}';
	}

	public List<Role> getRoles() {
		return roles;
	}
	public void setRoles(List<Role> roles) {
		this.roles = roles;
	}
	public Dep getDep() {
		return dep;
	}
	public void setDep(Dep dep) {
		this.dep = dep;
	}
	public Long getUuid() {
		return uuid;
	}
	public void setUuid(Long uuid) {
		this.uuid = uuid;
	}
	public String getUsername() {
		return username;
	}
	public void setUsername(String username) {
		this.username = username;
	}
	public String getPwd() {
		return pwd;
	}
	public void setPwd(String pwd) {
		this.pwd = pwd;
	}
	public String getName() {
		return name;
	}
	public void setName(String name) {
		this.name = name;
	}
	public Long getGender() {
		return gender;
	}
	public void setGender(Long gender) {
		this.gender = gender;
	}
	public String getEmail() {
		return email;
	}
	public void setEmail(String email) {
		this.email = email;
	}
	public String getTele() {
		return tele;
	}
	public void setTele(String tele) {
		this.tele = tele;
	}
	public String getAddress() {
		return address;
	}
	public void setAddress(String address) {
		this.address = address;
	}
	public java.util.Date getBirthday() {
		return birthday;
	}
	public void setBirthday(java.util.Date birthday) {
		this.birthday = birthday;
	}
	public String getNewPwd() {
		return newPwd;
	}
	public void setNewPwd(String newPwd) {
		this.newPwd = newPwd;
	}

	public Long getDepuuid() {
		return depuuid;
	}
	public void setDepuuid(Long depuuid) {
		this.depuuid = depuuid;
	}

	public Date getBirthdayFrom() {
		return birthdayFrom;
	}

	public void setBirthdayFrom(Date birthdayFrom) {
		this.birthdayFrom = birthdayFrom;
	}

	public Date getBirthdayTo() {
		return birthdayTo;
	}

	public void setBirthdayTo(Date birthdayTo) {
		this.birthdayTo = birthdayTo;
	}

}
